package com.qls.web.modules.ht.controller;

import com.qls.core.entity.HtSellRoom;
import com.qls.core.utils.R;
import com.qls.web.common.utils.PageUtils;
import com.qls.web.modules.ht.service.HtLogicRoomService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * @author yj
 * @email yj@gmail.com
 * @date 2021-08-25 10:50:46
 */
@RestController
@RequestMapping("ht/htlogicroom")
public class HtLogicRoomController {
    @Autowired
    private HtLogicRoomService htLogicRoomService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("ht:htlogicroom:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = htLogicRoomService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("ht:htlogicroom:info")
    public R info(@PathVariable("id") Long id) {
        HtSellRoom htLogicRoom = htLogicRoomService.getById(id);

        return R.ok().put("htLogicRoom", htLogicRoom);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("ht:htlogicroom:save")
    public R save(@RequestBody HtSellRoom htLogicRoom) {
        htLogicRoomService.save(htLogicRoom);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("ht:htlogicroom:update")
    public R update(@RequestBody HtSellRoom htLogicRoom) {
        htLogicRoomService.updateById(htLogicRoom);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("ht:htlogicroom:delete")
    public R delete(@RequestBody Long[] ids) {
        htLogicRoomService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
